#include<bits/stdc++.h>
#include<sys/types.h>
#include<unistd.h>
#include<sys/wait.h>
using namespace std;
int main()
{
  extern char** environ;
  putenv("VALUE=666");
  //
 //pid_t id = fork(); 
 //execl()
 //pid_t id = fork();
 //if(id == 0)
 //{
 //printf("before:I am a process,pid:%d,ppid:%d\n",getpid(),getppid());
 ////这类方法的标注写法
 //sleep(5);
 //execl("/usr/bin/ls","ls","-a","-l",nullptr);
 ////execl("usr/bin/wc","wc","-l",nullptr);
 //printf("after:I am a process,pid:%d,ppid:%d\n",getpid(),getppid());
 // exit(0);
 //}
 //pid_t ret = waitpid(id,nullptr,0);
 //if(ret > 0){
 //  printf("wait success,father pid:%d,ret pid:%d\n",getpid(),ret);
 //}
 //sleep(5);
 
 //char* const myargv[] = {"ls","-a","-l",nullptr};
 cout << "开始" << endl;
 //execl("usr/bin/ls","ls",nullptr);
 //execlp("ls","ls","-a","-t","-l",nullptr);
 //execv("/usr/bin/ls",myargv);
 //无论是我们的可执行程序,还是脚本,为什么能跨语言调用呢?
 //所有语言运行起来,本质都是进程！

 //execvp("ls",myargv);
 //execle("/usr/bin/ls","ls");
 //execl("./mainc","mainc",nullptr);
 //execl("/usr/bin/gcc","gcc","main.c",nullptr);
 //execl("/usr/bin/bash","bash","test.sh",nullptr);
 char* const myenv[] = {
   "VALUE1=666",
   "VALUE2=666"
 };
 //execle("./mainc","mainc","-a","-b",nullptr,environ);
 execle("./mainc","mainc","-a","-b",nullptr,myenv);
 cout << "结束" << endl;
 return 0;
}
